home *** CD-ROM | disk | FTP | other *** search
- head 1.4;
- branch ;
- access ;
- symbols sprited:1.4.1;
- locks ; strict;
- comment @ * @;
-
-
- 1.4
- date 91.12.04.14.43.13; author jhh; state Exp;
- branches 1.4.1.1;
- next 1.3;
-
- 1.3
- date 88.07.29.18.39.23; author ouster; state Exp;
- branches ;
- next 1.2;
-
- 1.2
- date 88.07.29.17.39.22; author ouster; state Exp;
- branches ;
- next 1.1;
-
- 1.1
- date 88.06.19.14.31.16; author ouster; state Exp;
- branches ;
- next ;
-
- 1.4.1.1
- date 91.12.10.15.46.11; author kupfer; state Exp;
- branches ;
- next ;
-
-
- desc
- @@
-
-
- 1.4
- log
- @added O_RDONLY, O_WRONLY, and O_RDWR to the flags. Also changed it
- to use IOC_SET_FLAGS instead of IOC_SET_BITS so that flags can
- be turned off
- @
- text
- @/*
- * fcntl.c --
- *
- * Procedure to map the Unix fcntl system call to Sprite.
- *
- * Copyright 1986 Regents of the University of California
- * All rights reserved.
- */
-
- #ifndef lint
- static char rcsid[] = "$Header: /sprite/src/lib/c/unixSyscall/RCS/fcntl.c,v 1.3 88/07/29 18:39:23 ouster Exp Locker: jhh $ SPRITE (Berkeley)";
- #endif not lint
-
- #include "sprite.h"
- #include "fs.h"
-
- #include "compatInt.h"
-
- #include <fcntl.h>
- #include <stdio.h>
-
- /*
- *----------------------------------------------------------------------
- *
- * fcntl --
- *
- * Procedure to map from Unix fcntl system call to Sprite Fs_IOControl.
- *
- * Results:
- * a value depending on the command, or
- * UNIX_SUCCESS the call was successful, or
- * UNIX_ERROR the call was not successful.
- * The actual error code stored in errno.
- *
- * Side effects:
- * Variable.
- *
- *----------------------------------------------------------------------
- */
-
- int
- fcntl(fd, cmd, arg)
- int fd; /* File to operate on. */
- int cmd; /* Type of command. */
- int arg; /* Optional argument to the command. */
- {
- ReturnStatus status;
- int value;
-
- switch (cmd) {
- case F_DUPFD:
- status = Fs_GetNewID(fd, &arg);
- value = arg;
- break;
-
- case F_GETFD:
- status = Fs_IOControl(fd, IOC_GET_FLAGS,
- 0, (Address) NULL,
- sizeof(value), (Address) &value);
- value = (value & IOC_CLOSE_ON_EXEC) ? 1 : 0;
- break;
-
- case F_SETFD:
- value = IOC_CLOSE_ON_EXEC;
- if (arg & 1) {
- status = Fs_IOControl(fd, IOC_SET_BITS,
- sizeof(value), (Address) &value,
- 0, (Address) NULL);
- } else {
- status = Fs_IOControl(fd, IOC_CLEAR_BITS,
- sizeof(value), (Address) &value,
- 0, (Address) NULL);
- }
- value = UNIX_SUCCESS;
- break;
-
- case F_GETFL: {
- int temp;
-
- status = Fs_IOControl(fd, IOC_GET_FLAGS,
- 0, (Address) NULL,
- sizeof(temp), (Address) &temp);
- value = 0;
- if (temp & IOC_APPEND) {
- value |= FAPPEND;
- }
- if (temp & IOC_NON_BLOCKING) {
- value |= FNDELAY;
- }
- if (temp & IOC_ASYNCHRONOUS) {
- value |= FASYNC;
- }
- switch(temp & (IOC_READ | IOC_WRITE)) {
- case IOC_READ :
- value |= O_RDONLY;
- break;
- case IOC_WRITE:
- value |= O_WRONLY;
- break;
- case (IOC_READ | IOC_WRITE) :
- value |= O_RDWR;
- break;
- }
- }
- break;
-
- case F_SETFL:
- value = 0;
- if (arg & FAPPEND) {
- value |= IOC_APPEND;
- }
- if (arg & FNDELAY) {
- value |= IOC_NON_BLOCKING;
- }
- if (arg & FASYNC) {
- value |= IOC_ASYNCHRONOUS;
- }
- status = Fs_IOControl(fd, IOC_SET_FLAGS,
- sizeof(value), (Address) &value,
- 0, (Address) NULL);
- value = UNIX_SUCCESS;
- break;
-
- case F_GETOWN: {
- Ioc_Owner owner;
-
- status = Fs_IOControl(fd, IOC_GET_OWNER,
- 0, (Address) NULL,
- sizeof(owner), (Address) &owner);
- if (owner.procOrFamily == IOC_OWNER_FAMILY) {
- value = -owner.id;
- } else {
- value = owner.id;
- }
- }
- break;
-
- case F_SETOWN: {
- Ioc_Owner owner;
-
- if (arg < 0) {
- owner.id = -arg;
- owner.procOrFamily = IOC_OWNER_FAMILY;
- } else {
- owner.id = arg;
- owner.procOrFamily = IOC_OWNER_PROC;
- }
- status = Fs_IOControl(fd, IOC_SET_OWNER,
- sizeof(owner), (Address) &owner,
- 0, (Address) NULL);
- value = UNIX_SUCCESS;
- }
- break;
-
- default:
- break;
- }
- if (status != SUCCESS) {
- errno = Compat_MapCode(status);
- return(UNIX_ERROR);
- }
- return(value);
- }
- @
-
-
- 1.4.1.1
- log
- @Initial branch for Sprite server.
- @
- text
- @d11 1
- a11 1
- static char rcsid[] = "$Header: /sprite/src/lib/c/unixSyscall/RCS/fcntl.c,v 1.4 91/12/04 14:43:13 jhh Exp $ SPRITE (Berkeley)";
- @
-
-
- 1.3
- log
- @Lint.
- @
- text
- @d11 1
- a11 1
- static char rcsid[] = "$Header: fcntl.c,v 1.2 88/07/29 17:39:22 ouster Exp $ SPRITE (Berkeley)";
- d93 11
- d118 3
- a120 7
- if (value == 0) {
- status = SUCCESS;
- } else {
- status = Fs_IOControl(fd, IOC_SET_BITS,
- sizeof(value), (Address) &value,
- 0, (Address) NULL);
- }
- @
-
-
- 1.2
- log
- @Lint.
- @
- text
- @d11 1
- a11 1
- static char rcsid[] = "$Header: fcntl.c,v 1.1 88/06/19 14:31:16 ouster Exp $ SPRITE (Berkeley)";
- d82 1
- a82 1
- sizeof(temp), &temp);
- @
-
-
- 1.1
- log
- @Initial revision
- @
- text
- @d11 1
- a11 1
- static char rcsid[] = "$Header: fcntl.c,v 1.3 87/07/31 16:44:44 andrew Exp $ SPRITE (Berkeley)";
- d58 2
- a59 2
- 0, NULL,
- sizeof(value), &value);
- d67 2
- a68 2
- sizeof(value), &value,
- 0, NULL);
- d71 2
- a72 2
- sizeof(value), &value,
- 0, NULL);
- d81 1
- a81 1
- 0, NULL,
- d111 2
- a112 2
- sizeof(value), &value,
- 0, NULL);
- d121 2
- a122 2
- 0, NULL,
- sizeof(owner), &owner);
- d142 2
- a143 2
- sizeof(owner), &owner,
- 0, NULL);
- @
-